home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MOR55SRC.ZIP / MORIA / SOURCE / PRAYER.C < prev    next >
C/C++ Source or Header  |  1992-12-07  |  5KB  |  209 lines

  1. /* source/prayer.c: code for priest spells
  2.  
  3.    Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  4.  
  5.    This software may be copied and distributed for educational, research, and
  6.    not for profit purposes provided that this copyright and statement are
  7.    included in all such copies. */
  8.  
  9. #include "config.h"
  10. #include "constant.h"
  11. #include "types.h"
  12. #include "externs.h"
  13.  
  14.  
  15. /* Pray like HELL.                    -RAK-    */
  16. void pray()
  17. {
  18.   int i, j, item_val, dir;
  19.   int choice, chance, result;
  20.   register spell_type *s_ptr;
  21.   register struct misc *m_ptr;
  22.   register struct flags *f_ptr;
  23.   register inven_type *i_ptr;
  24. #ifdef ATARIST_MWC
  25.   int32u holder;
  26. #endif
  27.  
  28.   free_turn_flag = TRUE;
  29.   if (py.flags.blind > 0)
  30.     msg_print("You can't see to read your prayer!");
  31.   else if (no_light())
  32.     msg_print("You have no light to read by.");
  33.   else if (py.flags.confused > 0)
  34.     msg_print("You are too confused.");
  35.   else if (class[py.misc.pclass].spell != PRIEST)
  36.     msg_print("Pray hard enough and your prayers may be answered.");
  37.   else if (inven_ctr == 0)
  38.     msg_print ("But you are not carrying anything!");
  39.   else if (!find_range(TV_PRAYER_BOOK, TV_NEVER, &i, &j))
  40.     msg_print ("You are not carrying any Holy Books!");
  41.   else if (get_item(&item_val, "Use which Holy Book?", i, j, CNIL, CNIL))
  42.     {
  43.       result = cast_spell("Recite which prayer?", item_val, &choice, &chance);
  44.       if (result < 0)
  45.     msg_print("You don't know any prayers in that book.");
  46.       else if (result > 0)
  47.     {
  48.       s_ptr = &magic_spell[py.misc.pclass-1][choice];
  49.       free_turn_flag = FALSE;
  50.  
  51.       if (randint(100) < chance)
  52.         msg_print("You lost your concentration!");
  53.       else
  54.         {
  55.           /* Prayers.                    */
  56.           switch(choice+1)
  57.         {
  58.         case 1:
  59.           (void) detect_evil();
  60.           break;
  61.         case 2:
  62.           (void) hp_player(damroll(3, 3));
  63.           break;
  64.         case 3:
  65.           bless(randint(12)+12);
  66.           break;
  67.         case 4:
  68.           (void) remove_fear();
  69.           break;
  70.         case 5:
  71.           (void) light_area(char_row, char_col);
  72.           break;
  73.         case 6:
  74.           (void) detect_trap();
  75.           break;
  76.         case 7:
  77.           (void) detect_sdoor();
  78.           break;
  79.         case 8:
  80.           (void) slow_poison();
  81.           break;
  82.         case 9:
  83.           if (get_dir(CNIL, &dir))
  84.             (void) confuse_monster(dir, char_row, char_col);
  85.           break;
  86.         case 10:
  87.           teleport((int)(py.misc.lev*3));
  88.           break;
  89.         case 11:
  90.           (void) hp_player(damroll(4, 4));
  91.           break;
  92.         case 12:
  93.           bless(randint(24)+24);
  94.           break;
  95.         case 13:
  96.           (void) sleep_monsters1(char_row, char_col);
  97.           break;
  98.         case 14:
  99.           create_food();
  100.           break;
  101.         case 15:
  102.           for (i = 0; i < INVEN_ARRAY_SIZE; i++)
  103.             {
  104.               i_ptr = &inventory[i];
  105.               /* only clear flag for items that are wielded or worn */
  106.               if (i_ptr->tval >= TV_MIN_WEAR
  107.               && i_ptr->tval <= TV_MAX_WEAR)
  108. #ifdef ATARIST_MWC
  109.             i_ptr->flags &= ~(holder = TR_CURSED);
  110. #else
  111.             i_ptr->flags &= ~TR_CURSED;
  112. #endif
  113.             }
  114.           break;
  115.         case 16:
  116.           f_ptr = &py.flags;
  117.           f_ptr->resist_heat += randint(10) + 10;
  118.           f_ptr->resist_cold += randint(10) + 10;
  119.           break;
  120.         case 17:
  121.           (void) cure_poison();
  122.           break;
  123.         case 18:
  124.           if (get_dir(CNIL, &dir))
  125.             fire_ball(GF_HOLY_ORB, dir, char_row, char_col,
  126.                   (int)(damroll(3, 6)+py.misc.lev),
  127.                   "Black Sphere");
  128.           break;
  129.         case 19:
  130.           (void) hp_player(damroll(8, 4));
  131.           break;
  132.         case 20:
  133.           detect_inv2(randint(24)+24);
  134.           break;
  135.         case 21:
  136.           (void) protect_evil();
  137.           break;
  138.         case 22:
  139.           earthquake();
  140.           break;
  141.         case 23:
  142.           map_area();
  143.           break;
  144.         case 24:
  145.           (void) hp_player(damroll(16, 4));
  146.           break;
  147.         case 25:
  148.           (void) turn_undead();
  149.           break;
  150.         case 26:
  151.           bless(randint(48)+48);
  152.           break;
  153.         case 27:
  154.           (void) dispel_creature(CD_UNDEAD, (int)(3*py.misc.lev));
  155.           break;
  156.         case 28:
  157.           (void) hp_player(200);
  158.           break;
  159.         case 29:
  160.           (void) dispel_creature(CD_EVIL, (int)(3*py.misc.lev));
  161.           break;
  162.         case 30:
  163.           warding_glyph();
  164.           break;
  165.         case 31:
  166.           (void) dispel_creature(CD_EVIL, (int)(4*py.misc.lev));
  167.           (void) remove_fear();
  168.           (void) cure_poison();
  169.           (void) hp_player(1000);
  170.           break;
  171.         default:
  172.           break;
  173.         }
  174.           /* End of prayers.                */
  175.           if (!free_turn_flag)
  176.         {
  177.           m_ptr = &py.misc;
  178.           if ((spell_worked & (1L << choice)) == 0)
  179.             {
  180.               m_ptr->exp += s_ptr->sexp << 2;
  181.               prt_experience();
  182.               spell_worked |= (1L << choice);
  183.             }
  184.         }
  185.         }
  186.       m_ptr = &py.misc;
  187.       if (!free_turn_flag)
  188.         {
  189.           if (s_ptr->smana > m_ptr->cmana)
  190.         {
  191.           msg_print("You faint from fatigue!");
  192.           py.flags.paralysis =
  193.             randint((int)(5 * (s_ptr->smana-m_ptr->cmana)));
  194.           m_ptr->cmana = 0;
  195.           m_ptr->cmana_frac = 0;
  196.           if (randint(3) == 1)
  197.             {
  198.               msg_print("You have damaged your health!");
  199.               (void) dec_stat (A_CON);
  200.             }
  201.         }
  202.           else
  203.         m_ptr->cmana -= s_ptr->smana;
  204.           prt_cmana();
  205.         }
  206.     }
  207.     }
  208. }
  209.